﻿using OASystem.BLL.IService;
using OASystem.DAL;
using OASystem.Model;
using OASystem.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace OASystem.BLL.Service
{
    //记得修改Userinfo成自己要使用的实体
    public class Person_tailService : BaseRepository<Userinfo>, IPerson_tailService
    {
        BaseRepository<Departinfo> repository = new BaseRepository<Departinfo>();
        BaseRepository<Position> baseRepository = new BaseRepository<Position>();
        BaseRepository<Userinfo> user = new BaseRepository<Userinfo>();
        /// <summary>
        /// 查询部门集合
        /// </summary>
        /// <returns></returns>
        public ResponseResult QueryList()
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = repository.QueryList(a => true);
            return responseResult;
        }
        /// <summary>
        /// 查询职位集合
        /// </summary>
        /// <returns></returns>
        public ResponseResult QueryPosition()
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = baseRepository.QueryList(a => true);
            return responseResult;
        }
        /// <summary>
        /// 判断是否重复添加相同的数据
        /// </summary>
        /// <param name="maillist"></param>
        /// <returns></returns>
        public ResponseResult QueryPerson(string name)
        {
            ResponseResult result = new ResponseResult();
            Expression<Func<Userinfo, bool>> lambdaExpression = a => a.UserName == name;
            result.success = user.Exists(lambdaExpression);
            return result;
        }
    }
}
